package com.hippomeetsskunk.savanna.types.resource;

import java.util.Random;

import com.hippomeetsskunk.savanna.types.meta.EdibleType;
import com.hippomeetsskunk.savanna.types.meta.ResourceType;
import com.hippomeetsskunk.savanna.types.world.Location;

public class ResourceFactory {

	private Random random = new Random();

	public RelocatableObject createResource(ResourceType type){
		// create new things
		final double q = random.nextDouble() * 0.5 + 0.5;
		final double v = random.nextDouble() * 0.2 + 0.9; // +- 10%

		if (type.equals(EdibleType.PORK_MEAT)) return new Edible((EdibleType) type, 15.0 * v, q);
		if (type.equals(EdibleType.SMOKED_PORK_MEAT)) return new Edible((EdibleType) type, 25.0 * v, q);
		if (type.equals(EdibleType.ZUCCHINI)) return new Edible((EdibleType) type, 5.0 * v, q);

		if (type.equals(ResourceType.WHEAT)) return new Resource(type, 3.0 * v, q);
		if (type.equals(ResourceType.WHEAT_SEEDS)) return new Resource(type, 30.0 * v, q);

		throw new IllegalArgumentException("Unknown resource type " + type);
	}
	
	public LocatedObject createLocatedResource(ResourceType type, Location location){
		final double q = random.nextDouble() * 0.5 + 0.5;
		final double v = random.nextDouble() * 0.2 + 0.9; // +- 10%
		
		if (ResourceType.FIELD.equals(type)) return new Field(location, 36000.0 * v, q);
		throw new IllegalArgumentException("Unknown resource type " + type);
		
	}
}
